package executeEngine.methodInvoke.dynamicDispatch;

class Father {
    public void choice(Dog dog) {
        System.out.println("father choose dog");
    }
    public void choice(Cat cat) {
        System.out.println("father choose cat");
    }
}

class Son extends Father {
    public void choice(Dog dog) {
        System.out.println("son choose dog");
    }
    public void choice(Cat cat) {
        System.out.println("son choose cat");
    }
}

/**
 * 多分派
 */
public class Demo2 {
    public static void main(String[] args) {
        Father t1 = new Father();
        Father t2 = new Son();

        t1.choice(new Dog());
        t2.choice(new Cat());
    }
}
